<?php
/**
 * this is cloud search http request class test file
 *
 *
 */
require_once 'index.php';
require_once 'Framework/TestCase.php';
class DaoTest extends PHPUnit_Framework_TestCase 
{

    /**
     * test case, function name begin with  test, e.g.testSum
     * or use @test for not begin with test.
     *
     */
    public function testCreate()
    {
        $app = 12;
        $shard = 1;

        $dao = NICED_DaoFactory::create("ctp.thread");
        $dao->setApp($app);
        $dao->setShard($shard);
        $dao->appendWhere("1"); 
        $dao->appendWhere("app=".$app);
        $rs = $dao->execute();
        $this->assertTrue($rs->isSuccess());
        echo "sql is: ".$dao->getSQLWrapper()->render()."\r\n";
    }


    public function testCreateOnNoDaoFile()
    {
        $app = 12;
        $shard = 1;

        $dao = NICED_DaoFactory::create("system.dsn_tablename");
        $dao->appendWhere("1"); 
        $rs = $dao->execute();
        $this->assertTrue($rs->isSuccess());
        echo "sql is: ".$dao->getSQLWrapper()->render()."\r\n";
    }


    public function testTransactionDao()
    {
        $txn = new NICED_TransactionDao();
        $dao = NICED_DaoFactory::create('test');
        $dao->byId(1);
        $txn->attach($dao);
        $dao->execute();
        $txn->commit();
    }


    /**
     * execute before class
     *
     */
    public static function setUpBeforeClass()
    {

    }

    /**
     * execute before case
     *
     */
    protected function setUp()
    {

    }

    /**
     *
     * execute before assert
     */
    protected function assertPreConditions()
    {

    }

    /**
     *
     * execute after assert
     */
    protected function assertPostConditions()
    {

    }

    /**
     * execute after case
     */
    protected function tearDown()
    {

    }

    /**
     * execute after class
     *
     */
    public static function tearDownAfterClass()
    {

    }


}//end class
